package com.tanhua.server.controller;

import com.tanhua.domain.vo.VoiceVo;
import com.tanhua.server.service.VoiceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * 桃花传音
 */
@RestController
@RequestMapping("/peachblossom")
public class VoiceController {

    @Autowired
    private VoiceService voiceService;
    /**
     * 桃花传音: 发送语言
     *
     * @param soundFile
     * @return
     */
    @PostMapping
    public ResponseEntity sendVoiceMessage(MultipartFile soundFile) {
        voiceService.save(soundFile);
        return ResponseEntity.ok(null);
    }

    /**
     * 桃花传音-接收语音
     */
    @GetMapping
    public ResponseEntity VoiceReceive() {
        //1. 接受请求参数
        //2. 调用service层进行处理
        VoiceVo voiceVo = voiceService.peachblossomReceive();
        //3. 返回结果
        return ResponseEntity.ok(voiceVo);
    }


}
